﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Topics_Menu : BaseZoneMenu
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BaseTopicPage page = this.Page as BaseTopicPage;
            if(page != null)
            {
                if (page.CurrentTopic != null)
                {
                    lnkTopicPosts.Text = string.Format(lnkTopicPosts.Text, page.CurrentTopic.Name);
                    lnkTopicFiles.Text = string.Format(lnkTopicFiles.Text, page.CurrentTopic.Name);
                    lnkTopicPosts.Visible = true;
                    lnkTopicFiles.Visible = true;
                    lnkTopicPosts.NavigateUrl = page.AppendQueryStringParameters(lnkTopicPosts.NavigateUrl);
                    lnkTopicFiles.NavigateUrl = page.AppendQueryStringParameters(lnkTopicFiles.NavigateUrl);
                }
                else
                {
                    lnkTopicPosts.Visible = false;
                    lnkTopicFiles.Visible = false;
                }

                if (page.CurrentGroup != null)
                {
                    lnkGroupFiles.Text = string.Format(lnkGroupFiles.Text, page.CurrentGroup.Name);
                    lnkGroupTopics.Text = string.Format(lnkGroupTopics.Text, page.CurrentGroup.Name);

                    lnkGroupFiles.Visible = true;
                    lnkGroupTopics.Visible = true;

                    lnkGroupFiles.NavigateUrl = page.AppendQueryStringParameters(lnkGroupFiles.NavigateUrl);
                    lnkGroupTopics.NavigateUrl = page.AppendQueryStringParameters(lnkGroupTopics.NavigateUrl);
                }
                else
                {
                    lnkGroupFiles.Visible = false;
                    lnkGroupTopics.Visible = false;
                }

                lnkTopics.NavigateUrl = page.AppendQueryStringParameters(lnkTopics.NavigateUrl);
                lnkTopicGroups.NavigateUrl = page.AppendQueryStringParameters(lnkTopicGroups.NavigateUrl);
            }
            SetIfSelected(lnkTopicPosts);
            SetIfSelected(lnkTopicFiles);
            SetIfSelected(lnkGroupFiles);
            SetIfSelected(lnkGroupTopics);
            SetIfSelected(lnkTopics);
            SetIfSelected(lnkTopicGroups);

            lnkTopicGroups.Visible = Page.User.HasRole(Acms.Bll.Role.Roles.Developer);
            
        }
    }
}
